<%@page import="com.kaishengit.pms.util.TimeNoteUtil"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<style type="text/css">
		body{
			background-image:url(img/bb.jpg);
			background-repeat:repeat-x;
		}
	</style>
</head>
<body class="body">
	<%@ include file="include/main-top.jsp" %>
	<div class="container">
	  <div class="row">
		<jsp:include page="include/left.jsp">
			<jsp:param value="contact" name="tag"/>
		</jsp:include>
		<div class="span9">
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0">
				<li class="active">
					<a href="contact.jspx?m=contact&projectid=${ep.project.id}"><i class="icon-user"></i>联系人</a>
				</li>
			</ul>
			<c:if test="${param.state == '2000' }">
			<div id="addcontact" class="alert alert-info fade in" >
	            <a href="#" data-dismiss="alert" class="close">×</a>
	            <strong>删除联系人成功！</strong>
	        </div>
		</c:if>
			<div class="well">
				<div class="row" style="height:600px">
					<div class="span3">
						<a href="contact.jspx?m=loginaddcontact" class="btn span2"><i class="icon-plus"></i>添加联系人</a>
						<div class="clear" style=""></div>
						<ul class="unstyled" style="margin-top:15px;float:left">
						
							<c:forEach var="contactlist" items="${contactlist}">
								<li style="line-height:30px" class="span3">
									<i class="icon-list-alt"></i><a href="javascript:;" ref="${contactlist.id}">${contactlist.name}</a>
								</li>
							</c:forEach>
						</ul>
					</div>
					<div class="span5" id="show" style="min-height:400px;border-left:1px solid #ccc;padding-left:15px;height:600px">
						
					</div>
			</div>
		</div>
	  </div>
	</div>
	</div>
	
	<script type="text/javascript">
		
		
		function del(obj){
			if(confirm("你确定要删除此练习人吗?(首先删除此练习人里的记录)")){
				var id = $(obj).attr("rel");
				var m = "deletecontact";
				$.get("contact.jspx",{m:m,contactid:id});
			}
		};
	
	
	
		$(document).ready(function(){
			$("a").click(function(){
				
			 var contactid = $(this).attr("ref");
				//第一次get请求  返回个人信息
				$.get("contact.jspx?m=contactnow", {contactid:contactid}, function(result){
					$("#show").text("");
					var name = result.name;
					//alert(name);
					var company = result.companyname;
					var mobile = result.mobile;
					//alert(name);
					var tel = result.tel;
					var email = result.email;
					var address = result.address;
					var website = result.website;
					var weibo = result.weibo;
					var nameDiv =$("<div>").text("姓名：" + name);
					
					$('#show').append($("<h3>").append(nameDiv));
					
					conpanyDiv = $("<div>").text("公司: " + company);
					$('#show').append(conpanyDiv);
					
					$("<br>").appendTo($('#show'));
					
    				
    				$("<div>").text("手机：" + mobile).appendTo($('#show'));
    				$("<div>").text("固话：" + tel).appendTo($('#show'));
    				$("<br>").appendTo($("#show"));
    				
    				$("<div>").text("电子邮件：" + email).appendTo($('#show'));
    				$("<div>").text("地址：" + address).appendTo($('#show'));
    				
    				$("<br>").appendTo($('#show'));
    				
    				$("<div>").append("网址：").append($("<a>").attr("href",website).text(website)).appendTo($('#show')); 
					$("<div>").append("微博：").append($("<a>").attr("href",weibo).text(weibo)).appendTo($('#show'));
					$("<br>").appendTo($("#show"));
					
					$("<a>").attr("class","btn btn-primary").attr("href","contact.jspx?m=updatecontact&id=" + contactid).text("编辑").appendTo($("#show"));
					//$("<a>").attr("class","btn btn-danger").attr("href","contact.jspx?m=deletecontact&contactid=" + contactid).text("删除").appendTo($("#show"));
					$("<a>").attr("class","btn btn-danger").attr("rel",contactid).attr("onclick","del(this)").attr("href","javascript:;").text("删除").appendTo($("#show"));
					$("<br>").appendTo($("#show"));
					//第二次get请求 得到记录集合
					$.get("contact.jspx?m=notenow", {contactid:contactid}, function(noteNow){
						
						var obj = noteNow;
						$("<div>").attr("class","line").html("记录").appendTo($("#show"));
						
						$("<hr>").appendTo($("#show"));
						
						$("<br>").appendTo($("#show"));
						
					$(obj).each(function(){
						$("<blockquote>").attr("id",this.id).html(this.content).appendTo($("#show"));
						$("<small>").html("-" + this.employee.username + " "+ this.creatime + "发布").appendTo($("#"+this.id));
					});
					
						$("<a>").attr("class","btn btn-primary").attr("href","contact.jspx?m=showallnote&contactid="+ contactid).html("查看所有记录").appendTo($("#show"));
					});
					

				});
			});
			
			
		
		});
		
		
	</script>
	
</body>

</html>